import 'package:dio/dio.dart';
import 'package:flutter1911/config/config.dart';

Future request(url, formData, {isCategory = false}) async {
  try {
    Response response;
    Dio dio = Dio();
    if (formData == null) {
      response = await dio.get(servicePath[url]!);
    } else if (isCategory) {
      response = await dio.get(servicePath[url]!,queryParameters: formData);
    } else {
      // response = await dio.get(servicePath[url]!, queryParameters: formData);
      response = await dio.get(servicePath[url]! + formData);
    }
    if (response.statusCode == 200) {
      return response.data;
    } else {
      throw Exception('后端接口出现异常,请求失败:$url');
    }
  } catch (e) {
    return print('ERROR:=====================>$e');
  }
}
